﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BoldBrick.Core.Logging;

namespace BoldBrick.Logging.Log4Net
{
    public class Log4NetLoggerInit : ILoggerInit
    {
        private static bool initialized = false;

        public static bool Initialized
        {
            get
            {
                return initialized;
            }
        }

        /*static Log4NetLogger()
        {
            if (Properties.Settings.Default.AutoConfigureLogger)
                Init();
        }*/
        
        #region ILoggerInit Members

        /// <summary>
        /// zinicializuje log4net
        /// </summary>
        public void Init()
        {
            lock (typeof(Log4NetLoggerInit))
            {
                log4net.Config.XmlConfigurator.Configure();

                initialized = true;

                ILogger defaultLogger = new Log4NetLogger(typeof(Log4NetLoggerInit));
                defaultLogger.Write(LogLevel.Info, "Logger init OK.", null);
            }
        }

        #endregion
    }
}
